package com.heima.user.controller.v1;

import com.heima.apis.user.ApUserRealnameControllerApi;
import com.heima.model.common.constants.AdminConstants;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import com.heima.user.service.ApUserRealnameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author 96558
 * @Date 2021/1/11 21:30
 * @Version 1.0
 **/
@RestController
@RequestMapping("/api/v1/auth")
public class ApUserRealnameController implements ApUserRealnameControllerApi {
    /**
     * 按照状态查询用户认证列表
     *
     * @param dto
     * @return
     */
    @Autowired
    private ApUserRealnameService apUserRealnameService;

    @PostMapping("/list")
    @Override
    public ResponseResult loadListByStatus(AuthDto dto) {
        return apUserRealnameService.loadListByStatus(dto);
    }

    /**
     * 审核通过
     *
     * @param dto
     * @return
     */
    @PostMapping("/authPass")
    @Override
    public ResponseResult authPass(@RequestBody  AuthDto dto) {
        return apUserRealnameService.updateStatusById(dto, AdminConstants.PASS_AUTH);
    }

    /**
     * 审核失败
     *
     * @param dto
     * @return
     */
    @PostMapping("/authFail")
    @Override
    public ResponseResult authFail(@RequestBody AuthDto dto) {
            return apUserRealnameService.updateStatusById(dto, AdminConstants.FAIL_AUTH);
    }
}
